﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AssetSelection.aspx.cs" Inherits="HRProject.Asset.AssetSelection" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Select assets</title>
    <link href="/css/tree.css" rel="stylesheet" type="text/css"/>
    <style type="text/css">
        /* tooltip */
        div.tooltip 
        {
	        outline:none;
	        float:left;
        }
        div.tooltip strong
        {
	        line-height:30px;
	        color:Blue;
	        font-size:large;
        }
        div.tooltip:hover
        {
	        text-decoration:none;
        }
        div.tooltip .tooltip-content
        {
	        z-index:10;
	        display:none;
	        padding:14px 20px;
	        margin-top:-30px;
	        margin-left:48px;
	        line-height:16px;
	        float:left;
        }
        div.tooltip:hover .tooltip-content
        {
	        display:inline;
	        position:absolute;
	        color:#111;
	        border:1px solid #DCA;
	        background:#fffAF0;
        }
        div.tooltip img.assetIcon
        {
        	width:100px;
        	height:100px;
        }
        div.tooltip div textarea
        {
        	float:left;
        	border-width:0px;
        	background-color:Transparent;
        	font-weight:bold;
        	overflow:auto;
        	color:Blue;
        }
        div.tooltip .label
        {
        	clear:left;
        }
        div.tooltip .info
        {
        	font-weight:bold;
        	padding-left:10px;
        	color:Blue;
        }
        .callout
        {
	        z-index:20;
	        position:absolute;
	        top:10px;
	        border:0;
	        left:-12px;
        }
        /*CSS3 extras*/
        a.tooltip span
        {
	        border-radius:4px;
	        -moz-border-radius: 4px;
	        -webkit-border-radius: 4px;
	        -moz-box-shadow: 5px 5px 8px #CCC;
	        -webkit-box-shadow: 5px 5px 8px #CCC;
	        box-shadow: 5px 5px 8px #CCC;
        }
    </style>
    <script type="text/javascript" language="javascript" src="/js/jquery-1.8.2.js"></script>
    <script type="text/javascript" language="javascript">
        function viewAssetType(link)
        {
            var node = $(link.parentNode);
            var idInput = node.find("input[name=typeId]");
            window.location.href = "/Asset/AssetSelection.aspx?assetTypeId=" + idInput.val();
        }
        
        function selectAssets()
        {
            var obj = new Object();
            var selectedAssets = $("input[name=selectedAsset]");
	        obj.selectedAssets = new Array();
	        var index = 0;
	        for (var i=0; i<selectedAssets.length; i++)
	        {
	            if (selectedAssets.eq(i).attr("checked") == "checked")
	            {
	                obj.selectedAssets[index] = new Object();
	                obj.selectedAssets[index].assetId = selectedAssets.eq(i).val();
	                obj.selectedAssets[index].assetName = jQuery.trim(selectedAssets.eq(i).parent().text());
	                index++;
	            }
	        }
	        window.returnValue = obj;
	        window.close();
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <div class="tree">
        <%
            printAssetTypeNode(Root);
        %>
        </div>
        <div style="float:left;margin-left:20px;">
            <div style="width:400px; height:300px; border:solid 1px blue;float:left;clear:both;">
                <%
                    for (int i = 0; i < Assets.Count; i++)
                    {%>
                    <div style="float:left;clear:both;" onmouseover="treeNodeMove(this);"
                        onmouseout="treeNodeOut(this);">
                        <div style="text-decoration:none;" class="tooltip">
                            <div class="asset-name">
                                <input type="checkbox" name="selectedAsset" value="<%= Assets[i].Id %>"/>
                                <%= Assets[i].Name %>
                            </div>
                            <div class="tooltip-content">
                                <img alt="" class="callout" src="/image/layout/callout.gif" />
                                <strong><%= Assets[i].Name %></strong><br />
                                <img alt="" src="<%= Assets[i].ImageUrl %>" style="float:right;" name="assetIcon" class="assetIcon"/>
                                <div class="label">Product ID</div>
                                <div class="info divProductId"><%= Assets[i].ProductId %></div>
                                <div class="label">Import date</div>
                                <div class="info divImportDate"><%= Assets[i].ImportDate.ToString("dd/MM/yyyy") %></div>
                                <div class="label">Terminate date</div>
                                <div class="info divTerminateDate"><%= Assets[i].TerminateDate.ToString("dd/MM/yyyy") %></div>
                                <div class="label">Description</div>
                                <textarea class="info divDescription" readonly="readonly"><%= Assets[i].Description %></textarea>
                            </div>
                        </div>
                        <div class="actionbar" style="top:0px;">
                            <div class="item edit" onclick="editAsset(this);"></div>
                            <div class="item remove" onclick="removeAsset(this);"></div>
                            <input type="hidden" name="assetId" value="<%= Assets[i].Id %>"/>
                            <input type="hidden" name="assetName" value="<%= Assets[i].Name %>"/>
                            <input type="hidden" name="assetProductId" value="<%= Assets[i].ProductId %>"/>
                            <input type="hidden" name="assetDescription" value="<%= Assets[i].Description %>"/>
                            <input type="hidden" name="assetImportDate" value="<%= Assets[i].ImportDate.ToString("dd/MM/yyyy") %>"/>
                            <input type="hidden" name="assetTerminateDate" value="<%= Assets[i].TerminateDate.ToString("dd/MM/yyyy") %>"/>
                            <input type="hidden" name="assetImageUrl" value="<%= Assets[i].ImageUrl %>"/>
                        </div>
                    </div>
                    <%}
                %>
            </div>
            <input type="button" value="Select" onclick="selectAssets();" style="float:left;clear:left"/>
            <input type="button" value="Cancel" onclick="window.returnValue='cancel';window.close();" style="float:left"/>
        </div>
    </div>
    </form>
</body>
</html>
